package com.gegao.somethinginteresting.utils.fresco;

import android.net.Uri;

/**
 * Created by zhangzhanzhong on 2015/08/28.
 */
public class UriUtils {

    public static Uri getUri(String uriStr, FRESCOURITYPE uriType, String packageName) {
        Uri uri = null;
        if (uriType == FRESCOURITYPE.HTTPURI) {
            uri = Uri.parse(uriStr);
        } else if (uriType == FRESCOURITYPE.RESOURCEURI) {
            uri = Uri.parse("res://" + packageName + "/" + uriStr);
        } else if (uriType == FRESCOURITYPE.FILEURI) {
            uri = Uri.parse("file://" + uriStr);
        } else if (uriType == FRESCOURITYPE.ASSETURI) {
            uri = Uri.parse("asset://" + uriStr);
        } else if (uriType == FRESCOURITYPE.CONTENTPROVIDERURI) {
            uri = Uri.parse("content://" + uriStr);
        }
        return uri;
    }

    public static Uri getUri(int resourceId, FRESCOURITYPE uriType, String packageName) {
        Uri uri = null;
        if (uriType == FRESCOURITYPE.RESOURCEURI) {
            uri = Uri.parse("res://" + packageName + "/" + resourceId);
        }
        return uri;
    }

}
